<!DOCTYPE html>
<html>
  
  <head>
    <meta charset="UTF-8">
    <title>团长每月佣金</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="./css/font.css">
    <link rel="stylesheet" href="./css/xadmin.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript" src="./lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="./js/xadmin.js"></script>
    <!-- 引入layui.css -->
    <link
            rel="stylesheet"
            href="https://www.layuicdn.com/layui-v2.5.6/css/layui.css"
    >
    <!-- 引入layui.js -->
    <script scr="https://www.layuicdn.com/layui-v2.5.6/layui.js"></script>

    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  
  <body>
    <div class="x-nav">
      <span class="layui-breadcrumb">
      </span>
      <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
    </div>


    <div class="x-body">
      <!--表单信息（搜索条件）-->
      <div class="layui-form">
        <div class="layui-form-item">
          <!--    日期选择器-->
          <div class="layui-inline"> <!-- 注意：这一层元素并不是必须的 -->
            <label class="layui-form-label">月份</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input" name="dateSelect" id="dateSelect" placeholder="请选择">
            </div>
          </div>

          <div class="layui-inline">
            <button id="getUser" class="layui-btn" lay-submit lay-filter="LAY-user-front-search">
              <i class="layui-icon layui-icon-search"></i>
            </button>
          </div>
        </div>
      </div>

<!--      今月营业额 提成 佣金数据-->
      <!--数据表格位置-->
      <table id="data-table" lay-filter="data-table"></table>

      <!--分页位置-->
      <div id="data-page" class="layui-table-page" lay-filter="data-page"></div>

    </div>


    <script>
      /**
       * 获取query参数后面的属性
       * @param {String} name 需要获取的参数
       */
      var gtGetQueryString = function(name){
        var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i')
        var url = window.location.href
        var search = url.substring(url.lastIndexOf('?') + 1)
        var r = search.match(reg)
        if (r != null) return decodeURI(r[2])
        return null
        window.gtGetQueryString = gtGetQueryString;
      }
      //调用方法进行取值
      var tzid=gtGetQueryString("cid");

      layui.use(['form','table','laypage','layer','laydate'], function() {
        var $ = layui.jquery
                ,form = layui.form,table = layui.table,laypage=layui.laypage,layer=layui.layer,laydate=layui.laydate;

        //执行一个laydate实例
        laydate.render({
          elem: '#dateSelect' //指定元素
          ,type: 'month'
        })

        let userTable=table.render({
          elem: "#data-table",
          url: "/colonel/getTzMonthData/"+tzid,
          id:"idTest",
          page:false,
          parseData: function(res){ //res 即为原始返回的数据
            console.log(res)
          return {
            "code": res.code, //解析接口状态
            "msg": res.msg, //解析提示文本
            "count": res.count, //解析数据长度
            "data": res.data //解析数据列表
          }},
          cols: [[
              {field: "yearmonth", title: "月份", align: "center",sort:true},
            {field: "turnover", title: "销售额（元）",align: "center",  sort:true},
            {field: "royalty", title: "提成（%）",align: "center"},
            {field: "money", title: "佣金（元）", align: "center",sort:true},
            ]],
          done:function (res, curr, count) {
              console.log("==============")
              console.log(res)
          }
        });

        form.on('submit(LAY-user-front-search)', function (data) {
          var filed = data.field;
          table.reload('idTest', {
              where: filed
          });
          return false;
        });

      })//layui结束

    </script>
  </body>

</html>